<template>
  <div id="app">
    <router-view></router-view>
    <div
      class="nav"
      v-if="$route && $route.meta && $route.meta.nav && $route.meta.nav.isNav"
    >
      <TabNav :navList="navList" :currentPath="$route.path" />
    </div>
  </div>
</template>

<script>
import TabNav from "@/components/TabNav";
export default {
  name: "App",
  components: {
    TabNav
  },
  data() {
    // 读取路由配置，生成导航列表
    const routes = this.$router.options.routes;
    const navs = [];
    routes.forEach(item => {
      if (item && item.meta && item.meta.nav && item.meta.nav.isNav) {
        navs.push({
          ...item.meta.nav,
          path: item.path
        });
      }
    });
    return {
      navList: navs
    };
  }
};
</script>

<style lang="less" scoped>
@import url("//at.alicdn.com/t/font_1987932_ts1dvbkvrcg.css");
#app {
  width: 100vw;
  height: 100vh;
  .icon {
    vertical-align: -0.15em;
    fill: currentColor;
    overflow: hidden;
  }
  .nav {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100vw;
    height: 8vh;
  }
}
</style>
